package nimy.info.android.dinnertime.connectivity;

import android.support.v4.content.AsyncTaskLoader;

/**
 * Use as the payload of the loader progress. When we load a data from remote
 * servie, always call and {@link AsyncTaskLoader#loadInBackground()}. This
 * method is not running in UI Thread and you can't update UI element to notify
 * user.
 * 
 * Instead of return the actual data directly, we can return {@link LoaderState}
 * with the exception information or the real data and then get the status in
 * {@link AsyncTaskLoader#deliverResult(Object)} method and update UI element.
 * 
 * @author 234aini@gmail.com 2012-11-1
 * 
 * @param <T>
 */
public class LoaderState<T> {

	private Throwable throwable;
	private T data;

	public LoaderState(Throwable throwable) {
		super();
		this.throwable = throwable;
	}

	public LoaderState(T data) {
		super();
		this.data = data;
	}

	public Throwable getThrowable() {
		return throwable;
	}

	public void setThrowable(Throwable throwable) {
		this.throwable = throwable;
	}

	public T getData() {
		return data;
	}

	public void setData(T data) {
		this.data = data;
	}

}
